<?php

use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Form;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Show;
use App\Admin\Extensions\Form\QuGuangDuShu;
use App\Admin\Extensions\Form\LeftRightVision;
use App\Admin\Extensions\Form\DateRangeFormat;
use App\Admin\Extensions\Form\DivideTitle;
use App\Admin\Extensions\Form\SelectTwo;
/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */
Form::extend('quguangdushu', QuGuangDuShu::class);
Form::extend('leftrightvision', LeftRightVision::class);
Form::extend('daterangeformat', DateRangeFormat::class);
Form::extend('dividetitle', DivideTitle::class);
Form::extend('selecttwo', SelectTwo::class);

Admin::css('/vendor/dcat-admin/dcat/css/main.css?v2.2.3-beta');
Admin::js('/vendor/dcat-admin/dcat/js/main.js?v2.2.2-beta');
Admin::js('/vendor/dcat-admin/dcat/js/jquery.serialize-object.min.js?v2.2.2-beta');

\App\Admin\Repositories\Shop::initShop();
admin_inject_section(Admin::SECTION['NAVBAR_AFTER_USER_PANEL'], function () {
    $shops = \App\Admin\Repositories\Shop::getUserShops();
    $html = '';
    foreach($shops as $shop) {
        $html .= "<a class='dropdown-item' href='javascript:;' onclick='setShop(".$shop->id.",\"".$shop->name."\")' >".$shop->name." </a>";
    }
    $shop = session('shop');
    return <<<HTML
<div class="btn-group" style="margin: 10px 15px; box-shadow: none;">
  <a type="button" class="btn btn-primary dropdown-toggle text-light" data-toggle="dropdown" aria-expanded="false" style="line-height:1.3">
    切换门店({$shop->name})
  </a>
  <div class="dropdown-menu">
    {$html}
  </div>
</div>
HTML;    
});

